#region license
# This file is part of Grawlix.
# 
# Grawlix is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# 
# Grawlix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public
# License along with Grawlix.  If not, see
# <http://www.gnu.org/licenses/>.
#endregion

"""Class to ease connection to a database, and relay queries."""

#TODO: Decide whether to delete this.

namespace Grawlix.Model.Data
/*import Grawlix
import System
import System.Data
import MySql.Data.MySqlClient



class DatabaseConnection():
	
	public def constructor():
		_log = Log.Find("Grawlix.Model.Data")
	
	def destructor():
		_connection.Close()

	def Connect(host as string, port as int, database as string, userid as string, password as string, pooling as bool):
	"""
	Connect to the specified server with the specified login data and specified database name.
	"""
		try:
			_location = "Server=${host};Port=${port};Database=${database};User ID=${userid};Password=${password};Pooling=${pooling}"
			_connection = MySqlConnection(_location)
			_connection.Open()
			_log.Info("Database should be started now")
		except e:
			_log.Fatal("mysql couldnt perform normally: " + e.Message)

	def RetrieveData(query as string) as List:
	"""
	Executes the query and returns the results as a List
	"""
		try:
			dbcmd as IDbCommand = _connection.CreateCommand()
			dbcmd.CommandText = query
			reader as IDataReader = dbcmd.ExecuteReader()
			
			templist as List = []
			while(reader.Read()):
				for i in range(reader.FieldCount):
					templist += [reader.GetValue(i)]
			reader.Close();
			reader = null;
			dbcmd.Dispose();
			dbcmd = null;
			return templist
		except e:
			_log.Fatal("mysql couldnt perform normally: " + e.Message)
	
	_location as string
	"""	The URL of the database. in the form of Server=localhost;Database=database;User ID=login;Password=password;Pooling=bool"""
	
	_connection as IDbConnection
	"""The actual connection to the database"""

	_log as Log
	"""Used for displaying errors and info on the console"""
*/